<!DOCTYPE html>
<html lang="en" xmlns:v-model="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>01vue</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app" >
    g_num={{g_num}}
    <counter v-on:plus="gNimPlus" v-on:reduce="gNumReduce" v-bind:num="g_num"></counter>

</div>


</body>
<script type="text/javascript">
    const counter ={
        template:`
        <div>
           <button v-on:click="numPlus">+</button>
           <button v-on:click="numReduce">-</button>
       </div>
        `,

        data(){
            return {nmu:1}
        },
        methods: {
            numPlus(){
                num++,
                    console.log("nmu="+this.num)
                return this.$emit("plus")
            },
            numReduce(){
                num--,
                    console.log("num="+this.num)
                return this.$emit("redce")
            }
        }

    }

    Vue.component("counter",counter);

    var app =new Vue({
        el:"#app",
        data:{
            msg:"内容"
        },

    })

</script>
</html>